import type { ApiRequest } from '@/types/apis.d'
import { request } from '../index'
import type { CollectFormType } from '@/views/modules/collect-manage/public-type'

export interface CollectManageRequest {
  // 采集列表
  'collectManager.collectManagerList': {
    limit?: number
    offset?: number
    status?: number
    resource_type?: number
    site_id?: string
    content_type?: number
    name?: string
  }
  'collectManager.collectOrder': {
    id: string
    order: number
  }
  // 资源分类
  'collectManager.resourceClassification': {
    addr?: string
    key?: string
    file_type_list?: number[]
    collect_scope?: number
    collect_id?: string
  }

  // 添加采集
  'collectManager.addCollect': CollectFormType

  // 采集详情
  'collectManager.collectFormInfo': {
    collect_id: string
  }

  // 编辑采集
  'collectManager.updateCollect': CollectFormType

  // 采集确认
  'collectManager.collectConfirm': {
    collect_id: string
    distribute_type: number
    collect_scope: number
    price_set: number
    coin_set: number[]
    time_type: number | null
  }

  // 更新采集状态-单个
  'collectManager.updateCollectStatusSingle': {
    id: string
    status: number
  }

  // 更新采集状态-多个
  'collectManager.updateCollectStatusMultiple': {
    batch_id: string[]
    status: number
  }

  // 删除采集-单个
  'collectManager.deleteCollectSingle': {
    id: string
  }

  // 删除采集-多个
  'collectManager.deleteCollectMultiple': {
    ids: string[]
  }

  // 删除采集任务-单个
  'collectManager.deleteCollectTaskSingle': {
    id: string
  }

  // 删除采集任务-多个
  'collectManager.deleteCollectTaskMultiple': {
    ids: string[]
  }
  //更新任务状态-多个
  'collectManager.updateTaskStatusMultiple': {
    batch_id: string[]
    status: number
  }
  //更新任务状态-单个
  'collectManager.updateTaskStatusSingle': {
    id: string
    status: number
  }
  // 采集日志列表
  'collectManager.collectLogList': {
    limit: number
    offset: number
    resource_type: number | undefined
    content_type: number | undefined
    resource_name?: string
    start_time?: number | null
    end_time?: number | null
  }

  // 采集日志明细列表
  'collectManager.collectLogDetailedList': {
    limit: number
    offset: number
    log_id: string
    category?: string
    sub_category?: string
    content_type?: number
    resource_name?: string
    start_time?: number | null
    end_time?: number | null
  }
  //资源库列表
  'collectManager.getCollectSourceList': {
    collect_id: string | undefined
    category: string
    sub_category: string
    video_name: string
    offset: number
    limit: number
  }
  //采集任务列表
  'collectManager.getCollectTaskList': {
    status: number | undefined
    content_type: number | undefined
    task_name: number | undefined
    offset: number
    limit: number
  }
  //创建任务
  'collectManager.addTask': {
    task_name: StrType
    collect_id: string | undefined
    collect_scope: NumType
    task_rule: NumType
    collect_date: string | undefined
    task_time: string[]
    content_distribute: NumType
    price_set: number
    coin_set: number[]
    status: number
    order: NumType
  }
  //更新采集任务
  'collectManager.updateTask': {
    id?: string
    task_name: StrType
    collect_id: string | undefined
    collect_scope: NumType
    task_rule: NumType
    collect_date: string | undefined
    task_time: string[]
    content_distribute: NumType
    price_set: number
    coin_set: number[]
    status: number
    order: NumType
  }
  //获取任务
  'collectManager.getTask': {
    id: string
  }
  //停止采集
  'collectManager.stopCollect': {
    id: string
  }
  //停止采集任务
  'collectManager.stopTaskCollect': {
    id: string
  }
  //获取种源一二级分类
  'collectManager.seedCategory': {
    collect_id: string
  }
}
type StrType = string | null
type NumType = number | null
// 采集列表
export const getCollectManagerList = (params?: ApiRequest['collectManager.collectManagerList']) =>
  request.get('v1/collect/list', params)
// 采集排序
export const collectOrder = (data?: ApiRequest['collectManager.collectOrder']) =>
  request.post('v1/collect/order/update', data)

// 资源分类
export const getSourceClassification = (params?: ApiRequest['collectManager.resourceClassification']) =>
  request.get('v1/collect/source/category/get', params)

// 添加采集
export const addCollect = (data?: ApiRequest['collectManager.addCollect']) =>
  request.post<'collectManager.addCollect', any>('v1/collect/create', data)

// 采集详情
export const getCollectInfo = (params?: ApiRequest['collectManager.collectFormInfo']) =>
  request.get('v1/collect/info', params)

// 编辑采集
export const updateCollect = (data?: ApiRequest['collectManager.updateCollect']) =>
  request.post<'collectManager.updateCollect', any>('v1/collect/update', data)

// 采集确认
export const collectConfirm = (data?: ApiRequest['collectManager.collectConfirm']) =>
  request.post<'collectManager.collectConfirm', any>('v1/collect/confirm', data)
//根据种源资源id进行采集
export const collectById = (data?: ApiRequest['collectManager.collectConfirm']) =>
  request.post<'collectManager.collectConfirm', any>('v1/collect/source/movie/collect', data)
// 更新采集状态-单个
export const updateCollectStatusSingle = (data?: ApiRequest['collectManager.updateCollectStatusSingle']) =>
  request.post<'collectManager.updateCollectStatusSingle', any>('v1/collect/status/update', data)

// 更新采集状态-多个
export const updateCollectStatusMultiple = (data?: ApiRequest['collectManager.updateCollectStatusMultiple']) =>
  request.post<'collectManager.updateCollectStatusMultiple', any>('v1/collect/status/batch_update', data)

// 删除采集站点-单个
export const deleteCollectSingle = (data?: ApiRequest['collectManager.deleteCollectSingle']) =>
  request.post<'collectManager.deleteCollectSingle', any>('v1/collect/delete', data)

// 删除采集站点-多个
export const deleteCollectMultiple = (data?: ApiRequest['collectManager.deleteCollectMultiple']) =>
  request.post<'collectManager.deleteCollectMultiple', any>('v1/collect/batch_delete', data)

// 删除采集任务-单个
export const deleteCollectTaskSingle = (data?: ApiRequest['collectManager.deleteCollectTaskSingle']) =>
  request.post<'collectManager.deleteCollectTaskSingle', any>('v1/collect/task/delete', data)

// 删除采集任务-多个
export const deleteCollectTaskMultiple = (data?: ApiRequest['collectManager.deleteCollectTaskMultiple']) =>
  request.post<'collectManager.deleteCollectTaskMultiple', any>('v1/collect/task/delete_batch', data)

// 采集日志列表
export const getCollectLogList = (params?: ApiRequest['collectManager.collectLogList']) =>
  request.get('v1/collect/log/list', params)

// 采集日志明细列表
export const getCollectLogDetailedList = (params?: ApiRequest['collectManager.collectLogDetailedList']) =>
  request.get('v1/collect/log_detail/list', params)

//资源库列表
export const getCollectSourceList = (params?: ApiRequest['collectManager.getCollectSourceList']) =>
  request.get('v1/collect/source/movie/list', params)
//采集任务列表
export const getCollectTaskList = (params?: ApiRequest['collectManager.getCollectTaskList']) =>
  request.get('v1/collect/task/list', params)
// 创建任务
export const addTask = (data?: ApiRequest['collectManager.addTask']) =>
  request.post<'collectManager.addTask', any>('v1/collect/task/add', data)
// 更新任务
export const updateTask = (data?: ApiRequest['collectManager.updateTask']) =>
  request.post<'collectManager.updateTask', any>('v1/collect/task/update', data)
//获取任务
export const getTask = (params?: ApiRequest['collectManager.getTask']) => request.get('v1/collect/task/get', params)
// 更新任务状态-单个
export const updateTaskStatusSingle = (data?: ApiRequest['collectManager.updateTaskStatusSingle']) =>
  request.post<'collectManager.updateTaskStatusSingle', any>('v1/collect/task/status/update', data)
// 更新任务状态-多个
export const updateTaskStatusMultiple = (data?: ApiRequest['collectManager.updateTaskStatusMultiple']) =>
  request.post<'collectManager.updateTaskStatusMultiple', any>('v1/collect/task/status/batch_update', data)
//停止采集
export const stopCollect = (data?: ApiRequest['collectManager.stopCollect']) =>
  request.post<'collectManager.stopCollect', any>('v1/collect/stop', data)
//停止采集任务
export const stopTaskCollect = (data?: ApiRequest['collectManager.stopTaskCollect']) =>
  request.post<'collectManager.stopTaskCollect', any>('v1/collect/task/stop', data)
//停止采集任务
export const seedCategory = (params?: ApiRequest['collectManager.seedCategory']) =>
  request.get<'collectManager.seedCategory', any>('v1/collect/get_seed_category', params)
